package com.huika.dealontop.control.myinfo.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RatingBar;
import android.widget.TextView;

import com.huika.dealontop.R;
import com.huika.dealontop.control.base.BaseAda;
import com.huika.dealontop.support.domain.MyEvaluateBean;
import com.huika.dealontop.utils.DateTimeTool;

/**
 * Description:
 * Created by zhouweiyong on 2015/11/16.
 */
public class MyEvaluateAdapter extends BaseAda<MyEvaluateBean> {

    public MyEvaluateAdapter(Context context) {
        super(context);
    }


    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder vh = null;
        if (view == null) {
            view = mInflater.inflate(R.layout.myevaluate_lvitem, viewGroup, false);
            vh = new ViewHolder(view);
            view.setTag(vh);
        } else {
            vh = (ViewHolder) view.getTag();
        }
        MyEvaluateBean myEvaluateBean = getItem(i);
        vh.rb_score_ml.setRating(Float.parseFloat(myEvaluateBean.evaluateScore));
        vh.tv_score_ml.setText(myEvaluateBean.evaluateScore);
//        if ("1".equals(mContext.getString(R.string.common_lang))){
//            vh.tv_time_ml.setText(DateTimeTool.ymdhmsDate(Long.parseLong(myEvaluateBean.evaluateTime)/1000));
//        }else{
//            vh.tv_time_ml.setText(DateTimeTool.dmyhmsDate(Long.parseLong(myEvaluateBean.evaluateTime)/1000));
//        }
        vh.tv_time_ml.setText(DateTimeTool.dmyhmsDate(Long.parseLong(myEvaluateBean.evaluateTime) / 1000));
        vh.tv_content_ml.setText(myEvaluateBean.evaluateContent);
        if (!TextUtils.isEmpty(myEvaluateBean.merchantReply)) {
            vh.tv_reply_ml.setVisibility(View.VISIBLE);
            vh.tv_reply_ml.setText(myEvaluateBean.merchantReply);
        }
        return view;
    }

    class ViewHolder {
        public RatingBar rb_score_ml;
        public TextView tv_score_ml;
        public TextView tv_time_ml;
        public TextView tv_content_ml;
        public TextView tv_reply_ml;

        public ViewHolder(View view) {
            rb_score_ml = (RatingBar) view.findViewById(R.id.rb_score_ml);
            tv_score_ml = (TextView) view.findViewById(R.id.tv_score_ml);
            tv_time_ml = (TextView) view.findViewById(R.id.tv_time_ml);
            tv_content_ml = (TextView) view.findViewById(R.id.tv_content_ml);
            tv_reply_ml = (TextView) view.findViewById(R.id.tv_reply_ml);
        }
    }
}
